package ioc06;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Calendar;
import java.util.Date;

/**
 * Author:shixiaojun@itany.com
 * Date:2022/3/4 15:50
 * Version:1.0-SNAPSHOT
 */
public class Test {

    public static void main(String[] args) {
//        ObjectFactory factory = new ObjectFactory();
//        SomeService someService = (SomeService) factory.getObject();
        ApplicationContext ac = new ClassPathXmlApplicationContext("ioc06/spring.xml");
        SomeService someService = (SomeService) ac.getBean("someService");

        someService.doSome();
        someService.doOther();

        // 练习
        // 通过Spring管理date
        Calendar calendar = Calendar.getInstance();
        Date date = calendar.getTime();
        Date date2 = (Date) ac.getBean("date");
        System.out.println(date);
        System.out.println(date2);

    }

}
